from PySide2 import QtGui
from PySide2.QtWidgets import QMainWindow, QSplitter

from test2.menu.flow_menu import FlowMenuBar
from test2.split.plugin_view import PluginView
from test2.tab.tab_widget import TabWidget


class FlowApp(QMainWindow):
    def __init__(self, parent=None):
        super(FlowApp, self).__init__(parent)
        self._init_ui()

    def _init_ui(self):
        # 添加 menu
        menu_bar = FlowMenuBar()
        self.setMenuBar(menu_bar)
        # 添加左侧
        splitter = QSplitter(self)
        left = PluginView()
        splitter.addWidget(left)
        right = TabWidget()
        splitter.addWidget(right)
        self.setCentralWidget(splitter)


if __name__ == "__main__":
    # Import local modules
    from dayu_widgets import dayu_theme
    from dayu_widgets.qt import application

    with application() as app:
        test = FlowApp()
        test.setWindowTitle("Flow Data")
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("doc/logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        app.setWindowIcon(icon)
        dayu_theme.set_theme("light")
        dayu_theme.apply(test)
        test.show()
